<!DOCTYPE html>
<html lang='en'>
<meta charset='utf-8'>
<html>
<head>
    <title>OAuth2.0网页授权</title>
    <meta name="viewport" content="width=device-width,user-scalable=0">
    <style type="text/css">
        *{margin:0; padding:0}
        table{border:1px dashed #B9B9DD;font-size:12pt}
        td{border:1px dashed #B9B9DD;word-break:break-all; word-wrap:break-word;}
    </style>
</head>
<body>

<table width="100%" cellspacing="0" cellpadding="0">
        <tr><td width="20%">属性</td><td width="80%">值</td></tr>
        <tr><td>OpenID</td><td id="openid"></td></tr>
        <tr><td>关注</td><td id="subscribe"></td></tr>
        <tr><td>关注时间</td><td id="subscribeTime"></td></tr>
        <tr><td>语言</td><td id="language"></td></tr>
        <tr><td>昵称</td><td id="nickname"></td></tr>
        <tr><td>性别</td><td id="sex"></td></tr>
        <tr><td>国家</td><td id="country"></td></tr>
        <tr><td>省份</td><td id="province"></td></tr>
        <tr><td>城市</td><td id="city"></td></tr>
        <tr><td>头像</td><td id="headimgUrl"></td></tr>
    </table>

</body>
<script type='text/javascript' src="../js/jquery.js" ></script>
<script type="text/javascript">
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
    }

 var code=getQueryString("code");
 var state=getQueryString("state");

 $.get("/xProgram/oauth/getUserInfo.do", {
     code:code,
     state:state,
     campusId:1
}, function(text) {

	  var obj = $.parseJSON(text);
   $("#openid").html(obj.openid);
   $("#nickname").html(obj.nickName);
   $("#sex").html(obj.sex);
   $("#country").html(obj.country);
   $("#province").html(obj.province);
   $("#city").html(obj.city);
    $("#subscribe").html(obj.subscribe);
   $("#subscribeTime").html(obj.subscribeTime); 
   $("#language").html(obj.language);
   $("#headimgUrl").html("<img src='"+obj.headimgUrl+"'  width='80px' height='auto'>");
});

 console.log("cookie="+document.cookie);
 
</script>
</html>